package com.example.administrator.myapplication.base;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by Administrator on 2016/3/30 0030.
 */
public class BaseActivity extends Activity{
    //起动Activity时调用此方向   一般用来做初始化工作
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        //全屏
        setFullScreen();
        LogUtil.d(this, "onCreate.......");
    }

    //即将可见时调用此方向
    @Override
    protected void onStart()
    {
        LogUtil.d(this,"onStart.......");
        super.onStart();
    }

    //用户可以看见并且交互的时候
    @Override
    protected void onResume()
    {
        super.onResume();
        LogUtil.d(this,"onResume.......");
    }

    //当这个窗口没有被完全覆盖时   一般用来保存一些临时数据
    @Override
    protected void onPause()
    {
        super.onPause();
        LogUtil.d(this,"onPause.......");
    }

    //当这个窗口完全不可见
    @Override
    protected void onStop()
    {
        super.onStop();
        LogUtil.d(this,"onStop.......");
    }

    //当这个窗口要销毁时   用来做清理性工作
    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        LogUtil.d(this,"onDestroy.......");
    }

    @Override
    protected void onRestart()
    {
        super.onRestart();
        LogUtil.d(this,"onRestart.......");
    }

    /**
     * 设置为全屏
     * setFullScreen:
     * @param  @return
     * @Exception
     */
    protected void setFullScreen()
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);  //无title
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  //全屏
    }

    //窗口的跳转
    /*****窗口的跳转******/
    protected void startActivity(Class<?> cls)
    {
      /*  Intent intent = new Intent(this, cls);
        startActivity(intent);*/
        startActivity(cls, null);
    }

    protected void startActivity(Class<?> cls,Bundle bdl)
    {
        Intent intent = new Intent(this, cls);
        if(bdl!=null)
        {
            intent.putExtras(bdl);
        }
        startActivity(intent);
    }
}
